/**
 * 
 */
package com.longevityassistant.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Window;


/**
 * 加载页面，在启动时显示一下就自动消失
 * @author LiJinHua
 * @version [Android 1.0.0, 2012-5-17]
 */
public class LoadingActivity extends Activity {
	
	private final static String TAG = "LoadingActivity";
	
	private static final int FINISH_START_PAGE = 1;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		
		setContentView(R.layout.layout_loading);
		
	}
	
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		mHandler.sendEmptyMessage(333);
		//启动页显�?秒后自动消失
		mHandler.sendEmptyMessageDelayed(FINISH_START_PAGE, 3000);
		
	}
	
	private Handler mHandler = new Handler(){
		@Override
		public void handleMessage(Message msg) {
			// TODO Auto-generated method stub
			super.handleMessage(msg);
			
			switch (msg.what) {
			case FINISH_START_PAGE:
				//启动首页
				Intent intent = new Intent(LoadingActivity.this, MainActivity.class);
				
				startActivity(intent);
				
				finish();
				
				Log.d(TAG, "LoadingActivity Finish !");
				break;
			}
		}
	};
	
	protected void onPause() {
		super.onPause();
		mHandler.removeMessages(FINISH_START_PAGE);
	};
	
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		

	}
	

	
}
